<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css" />
    <style>
    </style>
</head>
<style>
    .home:before {
        content: url(../image/home.png);
    }

    .refresh:before {
        content: url(../image/refresh.png);
    }

    .company:before {
        content: url(../image/company.png);
    }

    .pa-title {
        font-size: 17px;
        color: black;
        font-weight: bold;
    }

    .pa-title-content {
        font-size: 17px;
        color: black;
    }

    body {
        background-color: #D9D8DB;
    }

    .pa_scjj_t {
        background-color: #254060;
        height: 377px;
        color: white;
        overflow: auto;
    }

    .scjj_title {
        border: 1px solid #797979;
        height: 50px;
        line-height: 50px;
        text-align: center;
        font-size: 20px;
        font-weight: bold;
    }

    .scjj_content {
        border: 1px solid #797979;
        height: 100px;
        line-height: 25px;
        text-align: left;
        font-size: 15px;
        overflow: auto;
    }

    .pa_scjj_t1 {
        margin-top: 5px;
        height: 70px;
        color: white;
    }

    .pa_scjjProd {
        font-size: 15px;
        float: left;
        height: 58px;
        line-height: 58px;
        text-align: center;
        margin-left: 5px;
    }

    .pa_scjj_but {
        height: 58px;
        line-height: 58px;
        float: left;
        width: 50px;
        font-size: 17px;
        color: white;
        text-align: center;
        background-color: green;
        margin-left: 10px;
    }

    .pa_scjj_but1 {
        height: 58px;
        line-height: 58px;
        float: left;
        width: 75px;
        font-size: 17px;
        color: white;
        text-align: center;
        background-color: green;
        margin-left: 10px;
    }

    .footerLabel {
        color: white;
        float: left;
        font-size: 15px;
        height: 70px;
        line-height: 70px;
        text-align: center;
    }

    .footerContent {
        color: black;
        float: left;
        font-size: 15px;
        background-color: white;
        height: 40px;
        line-height: 40px;
        width: 140px;
        margin-top: 15px;
    }

    .selectClass {
        color: white;
        margin-left: 37%;
        font-size: 15px;
        margin-top: 20px;
    }

    .footerContent input {
        height: 40px;
        min-height: 40px;
    }

    p {
        font-size: 17px;
        color: black;
        font-weight: bold;
        text-align: center;
    }
</style>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #D9D8DB">
        <div style="width: 10%;height: 60px;float: left;padding-top: 6px;">
            <a class="aui-pull-left aui-btn ">
                <span class="aui-iconfont company"></span>
            </a>
        </div>
        <div style="width: 10%;height: 60px;float: left;">
            <div style="text-align: left;">
                <span class="pa-title">富晟安创</span>
            </div>
        </div>
        <div style="width: 70%;height: 60px;float: left;">
            <div style="width:20%; float: left; text-align: left;">
                <span class="pa-title-content" id="locationName"></span>
            </div>
            <div style="width:20%; float: left; text-align: left;">
                <span class="pa-title-content" id="workCenterName"></span>
            </div>
            <div style="width:20%; float: left; text-align: left;">
                <span class="pa-title-content" id="workCellName"></span>
            </div>
            <div style="width:40%; float: left; text-align: left;">
                <span class="pa-title-content" id="nowDate"></span>
            </div>
        </div>

        <div style="width: 5%;height: 50px;float: left;">
            <a class="aui-pull-right aui-btn " onclick="refresh()">
                <span class="aui-iconfont refresh"></span>
            </a>
        </div>
        <div style="width: 5%;height: 50px;float: left;">
            <a class="aui-pull-right aui-btn" onclick="closeWin()">
                <span class="aui-iconfont home"></span>
            </a>
        </div>
    </header>
    <div class="aui-content">
        <div class="aui-flex-col aui-flex-center" style="height: 30px;">
            <div class="aui-flex-item-12">
                <p>生产交接</p>
            </div>
        </div>
        <div class="aui-flex-col aui-flex-center">
            <div class="aui-flex-item-12">
                <div class="aui-flex-item-3">
                    <div class="aui-flex-col">
                        <div class="aui-flex-item-12">
                            <div class="aui-list-item-inner" style="background-color: #D9D8DB; border: 0;">
                                <div class="aui-list-item-label pa_scjjProd"> 生产日期：</div>
                                <div class="aui-list-item-input"
                                    style="background-color: white;float: left;width: 130px;"
                                    onclick="timePicker('prodDate');">
                                    <input type="text" placeholder="选择日期" class="aui-input" id="prodDate">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="aui-flex-item-3">
                    <div class="aui-flex-col">
                        <div class="aui-flex-item-12">
                            <ul class="aui-list aui-form-list">
                                <li class="aui-list-item" style="background-color: #D9D8DB; border: 0;">
                                    <div class="aui-list-item-inner" style="background-color: #D9D8DB; border: 0;">
                                        <div class="aui-list-item-label" style="font-size: 15px;">班次：</div>
                                        <div class="aui-list-item-input" style="background-color: white;">
                                            <select id="shiftCode" onchange="doSearch()">
                                            </select>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <div class="aui-flex-item-3">
                    <div class="aui-flex-col">
                        <div class="aui-flex-item-12">
                            <ul class="aui-list aui-form-list">
                                <li class="aui-list-item" style="background-color: #D9D8DB; border: 0;">
                                    <div class="aui-list-item-inner" style="background-color: #D9D8DB; border: 0;">
                                        <div class="aui-list-item-label" style="font-size: 15px;">班组：</div>
                                        <div class="aui-list-item-input" style="background-color: white;">
                                            <select id="teamCode" onchange="doSearch()">
                                            </select>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="aui-flex-item-3">
                    <div class="aui-flex-col ">
                        <div class="aui-flex-item-12">

                            <div class="pa_scjj_but" onclick="doSearch()">查询
                            </div>
                            <div class="pa_scjj_but" onclick="save()">
                                提交
                            </div>
                            <div class="pa_scjj_but1" onclick="scrap()">
                                扫码报废
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="aui-flex-col aui-flex-center" style="margin-top: 1%;">
            <div class="aui-flex-item-12">
                <div class="aui-flex-col pa_scjj_t">
                    <div class="aui-flex-item-12">
                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>生产完成</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <div id="completeproduct"></div>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>产品质量</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <div id="productquality"></div>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>设备运行</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <div id="equipoperate"></div>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>工装模具</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <div id="tooling"></div>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>安全状况</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <select id="securitesituation" class="selectClass">
                                        <option value="">--请选择--</option>
                                        <option value="0">合格</option>
                                        <option value="1">不合格</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>现场5S</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <select id="scene5s" class="selectClass">
                                        <option value="">--请选择--</option>
                                        <option value="0">合格</option>
                                        <option value="1">不合格</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>工具点检</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <select id="toolcheck" class="selectClass">
                                        <option value="">--请选择--</option>
                                        <option value="0">完成</option>
                                        <option value="1">未完成</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col scjj_title">
                                <div class="aui-flex-item-12">
                                    <div>备注</div>
                                </div>
                            </div>
                            <div class="aui-flex-col scjj_content">
                                <div class="aui-flex-item-12">
                                    <input type='text' class='aui-input' style="color: white;text-align: center;"
                                        id="remark" value='' />
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col pa_scjj_t1">
                                <div class="aui-flex-item-12">
                                    <div class="footerLabel">
                                        交班人:
                                    </div>
                                    <div class="footerContent" style="background-color: #D7D7D7;">
                                        <input type="text" id="handover" disabled="true" />
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col pa_scjj_t1">
                                <div class="aui-flex-item-12">
                                    <div class="footerLabel">
                                        接班人:
                                    </div>
                                    <div class="footerContent">
                                        <input type="text" id="successor">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col pa_scjj_t1">
                                <div class="aui-flex-item-12">
                                    <div class="footerLabel">
                                        交班班长:
                                    </div>
                                    <div class="footerContent">
                                        <input type="text" id="handovmonitor">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="aui-flex-item-3">
                            <div class="aui-flex-col pa_scjj_t1">
                                <div class="aui-flex-item-12">
                                    <div class="footerLabel">
                                        接班班长:
                                    </div>
                                    <div class="footerContent">
                                        <input type="text" id="successmonitor">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">

    var equipUniqueId = "";

    //初始化
    apiready = function () {
        //获取设备唯一号
        equipUniqueId = localStorage.getItem('equipUniqueId');
        //产线工位信息
        document.getElementById("locationName").innerHTML = api.pageParam.locationName;
        document.getElementById("workCenterName").innerHTML = api.pageParam.workCenterName;
        document.getElementById("workCellName").innerHTML = api.pageParam.workCellName;
        document.getElementById("nowDate").innerHTML = getTimeCommon();
        //当前时间刷新
        window.setInterval("getTime()", 1000);

        //交班人
        $("#handover").val(localStorage.getItem('un'));

        //1:初始化当前日期
        crateDate();

        //2:查询
        doSearchTeamShift();

    }

    //时间刷新
    function getTime() {
        document.getElementById("nowDate").innerHTML = getTimeCommon();
    }

    //获取当前日期
    function crateDate() {
        if (api.pageParam.proddate == null || api.pageParam.proddate == "" || api.pageParam.proddate == undefined) {
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            $("#prodDate").val(year + "-" + month + "-" + day);
        } else {
            $("#prodDate").val(api.pageParam.proddate);
        }
    }

    //时间选择器
    function timePicker(id) {
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function (ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#" + id).val(date);

                doSearch();
            }
        });
    }

    //班组下拉框
    function doSearchTeamShift() {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAssemblyTeam";
        var data = {
            values: {
                workCenterCode: api.pageParam.workCenterCode,
                clientCode: equipUniqueId,
                un: un,
            }
        };
        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';

        ajaxForData(params, data, false, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //成功
                if (myobj.code == 0) {

                    //班組賦值
                    var list = eval(myobj.list);
                    var html = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < list.length; i++) {
                        html += "<option value='" + list[i].code + "'>" + list[i].name + "</option>";
                    }
                    $api.html($api.byId("teamCode"), html);
                    $("#teamCode").val(api.pageParam.teamCode);

                    //班次赋值
                    var listShift = eval(myobj.listShift);
                    var htmlShift = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < listShift.length; i++) {
                        htmlShift += "<option value='" + listShift[i].code + "'>" + listShift[i].name + "</option>";
                    }
                    $api.html($api.byId("shiftCode"), htmlShift);
                    $("#shiftCode").val(api.pageParam.shiftCode);

                    //传输参数日期班组班次不为空，查询交接班数据
                    if (api.pageParam.teamCode != null && api.pageParam.teamCode != "" && api.pageParam.teamCode != undefined) {
                        doSearch();
                    }
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert("网络连接超时!")
            }
        });
    }

    //查询交接班信息
    function doSearch() {
        var proddate = $("#prodDate").val();
        var shiftCode = $("#shiftCode").val();
        // var teamCode = $("#teamCode").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAssemblyProHandoverData";
        var data = {
            values: {
                workCenterCode: api.pageParam.workCenterCode,
                workCellCode: api.pageParam.workCellCode,
                proddate: proddate,
                // teamCode: teamCode,
                shiftCode: shiftCode,
                un: un,
            }
        };
        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';

        ajaxForData(params, data, false, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //成功
                if (myobj.code == 0) {
                    document.getElementById("completeproduct").innerHTML = myobj.data.completeproduct;
                    document.getElementById("productquality").innerHTML = myobj.data.productquality;
                    document.getElementById("equipoperate").innerHTML = myobj.data.equipoperate;
                    // document.getElementById("tooling").innerHTML = myobj.data.tooling;
                    $("#securitesituation").val(myobj.data.securitesituation);
                    $("#scene5s").val(myobj.data.scene5s);
                    $("#toolcheck").val(myobj.data.toolcheck);
                    $("#remark").val(myobj.data.remark);
                    if (myobj.data.handover == null || myobj.data.handover == "" || myobj.data.handover == undefined) {
                        $("#handover").val(un);
                    } else {
                        $("#handover").val(myobj.data.handover);
                    }

                    $("#successor").val(myobj.data.successor);
                    $("#handovmonitor").val(myobj.data.handovmonitor);
                    $("#successmonitor").val(myobj.data.successmonitor);
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert("网络连接超时!")
            }
        });
    }

    //保存
    function save() {
        var proddate = $("#prodDate").val();
        var teamCode = $("#teamCode").val();
        var shiftCode = $("#shiftCode").val();
        var completeproduct = document.getElementById("completeproduct").innerHTML;//生产完成
        var productquality = document.getElementById("productquality").innerHTML;//产品质量
        var equipoperate = document.getElementById("equipoperate").innerHTML;//设备运行
        var tooling = document.getElementById("tooling").innerHTML;//工装模具
        var securitesituation = $("#securitesituation").val();//安全状况
        var scene5s = $("#scene5s").val();//现场5S
        var toolcheck = $("#toolcheck").val();//工具点检
        var remark = $("#remark").val();//备注
        var handover = $("#handover").val();//交班人
        var successor = $("#successor").val();//接班人
        var handovmonitor = $("#handovmonitor").val();//交班班长
        var successmonitor = $("#successmonitor").val();//接班班长

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAssemblyProHandoverSave";
        var data = {
            values: {
                proddate: proddate,
                workCenterCode: api.pageParam.workCenterCode,
                workCellCode: api.pageParam.workCellCode,
                teamCode: teamCode,
                shiftCode: shiftCode,
                completeproduct: completeproduct,
                productquality: productquality,
                equipoperate: equipoperate,
                tooling: tooling,
                securitesituation: securitesituation,
                scene5s: scene5s,
                toolcheck: toolcheck,
                remark: remark,
                handover: handover,
                successor: successor,
                handovmonitor: handovmonitor,
                successmonitor: successmonitor,
                un: un
            }
        };

        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';

        api.showProgress({
            title: '保存中...',
        });

        ajaxForData(params, data, false, function (ret, err) {
            if (ret) {
                api.hideProgress();
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == 0) {
                    api.toast({
                        msg: "保存成功!",
                        duration: 3000
                    });

                    //查询生产交接信息
                    doSearch();
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                api.hideProgress();
                alert("网络连接超时!")
            }
        });
    }

    //扫码报废
    function scrap() {
        var proddate = $("#prodDate").val();
        var pageParam = api.pageParam;
        pageParam.proddate = proddate;
        pageParam.name = "productionAssemblyScjjFJ";

        //打开页面
        api.openWin({
            name: "productionAssemblyScrap",
            url: 'productionAssemblyScrap.html',
            pageParam: pageParam,
        });
    }

    //刷新按钮
    function refresh() {

        //获取设备唯一号
        equipUniqueId = localStorage.getItem('equipUniqueId');

        //查询生产交接信息
        doSearch();

    }

    //返回按钮
    function closeWin() {
        api.closeToWin({ name: api.pageParam.rootName });
        api.execScript({
            name: api.pageParam.rootName,
            script: 'refresh()'
        });
    }
</script>

</html>